
<?php 
/**
 * Show Employee Status function
 *
 * Provides Employee Status information
 *
 * @author Manas Kalucha <manaskalucha@gmail.com>
 */
include_once 'UTcheckAuth.php';
include_once 'UTerrorcode.php';
include_once 'UTDBGlobal.php';

function showEmployeeStatus($userName,$userPassHash)
{
	global $dbaddress;
	global $dbuser;
	global $dbpassword;
	global $dbdatabasename;
	
	$output = array();
	$auth = 0;
	if (checkAuthentication($userName, $userPassHash) == true) {
	
		$r = array();
		$conn = mysqli_connect($dbaddress, $dbuser, $dbpassword, $dbdatabasename);
		$sql = "SELECT * FROM employees";
		$result = mysqli_query($conn, $sql);
		$row = mysqli_fetch_row($result);
		
		if($result->num_rows>0){
	
			while($row = $result->fetch_assoc()){
				$r[count($r)]= array('empStatusCode' => $row['empID'] , 'empStatusDesc'=>$row['empStatus']);
			}
			$error = ErrorCode::successRead;
			$output = array('code' => $error, 'value' => $r);
		}
	} else {
		$error = ErrorCode::authFailRead;
		$output = array('code' => $error);
	}
	return $output;
}
//print_r(json_encode($r));

?>
